<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/10/29
 * Time: 10:01
 */

namespace app\MAPP\shop\mode\goodmanager;


use core\lib\BaseControlerDB;
use core\lib\Config;
use function core\p;

class func extends BaseControlerDB
{
    var $conf;
    function __USERFUNC()
    {
        $this->conf = Config::all("SQLlib\\shoping\\sql");
    }

    function addgoods($name,$info,$num,$price,$img){
        try{
            $id = $this->db->pre_exec($this->conf["MAXID"],[])[0]["MAX(id)"]+1;
            $this->db->pre_exec($this->conf["addgood"],[$id,$name,$info,$img]);
            $this->db->pre_exec($this->conf["addrepo"],[$id,$num,$price]);
        }catch (\ErrorException $e){
            p($e->getMessage());
        }
    }

    function listedit($page){
        $temp = new \app\MAPP\shop\mode\lists\func();
        $tem = $temp->lists($page);
        return $tem;
    }

    function getinfo($id){
        try{
            $temp = $this->db->pre_exec($this->conf["get_info"],[$id]);
            return $temp;
        }catch (\ErrorException $e){
            p($e->getMessage());
            die();
        }
    }

    function updategoods($id,$name,$num,$price,$info){
        try{
            $temp = $this->db->pre_exec($this->conf["updategood"],[$name,$info,$id]);
            $temp1 = $this->db->pre_exec($this->conf["updaterepo"],[$price,$num,$id]);
            p($temp);
            p($temp1);
        }catch (\ErrorException $e){
            p($e->getMessage());
            die();
        }
    }


}